package com.um.pasantiaum.cliente;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.parse.ParseUser;
import com.um.pasantiaum.DispatchActivity;
import com.um.pasantiaum.R;
import com.um.pasantiaum.empresa.MainActivityEmpresa;

public class MainActivity extends ActionBarActivity {
	
	private Button mNuevoPedido;
	private Button mPedidosAbiertos;
	private Button mHistorial;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
			
		mNuevoPedido = (Button)findViewById(R.id.pedido_nuevo);
		mNuevoPedido.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent i = new Intent(MainActivity.this, SelectCompanyActivity.class);
				Log.d("MAINACTIVITY", "si");

				startActivity(i);
				
			}
		});
		
		mPedidosAbiertos = (Button)findViewById(R.id.ordenes_abiertas);
		mPedidosAbiertos.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
			}
		});
		
		mHistorial = (Button)findViewById(R.id.historial);
		mHistorial.setOnClickListener(new OnClickListener() {
			
			
			@Override
			public void onClick(View v) {
				Intent i = new Intent(MainActivity.this, HistorialActivity.class);
				Log.d("MAINACTIVITY", "historial");

				startActivity(i);
				
			}
		});
		
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {		
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.log_out_menu, menu);
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId()){
		case R.id.log_out:
			ParseUser.logOut();
			// Start and intent for the dispatch activity
	        Intent intent = new Intent(MainActivity.this, DispatchActivity.class);
	        startActivity(intent);
	        finish();
	        return true;
	    default:
			return super.onOptionsItemSelected(item);
		}
	}

}
